import http from '@/service/http'
import type * as T from '@/types/api/index'
import CryptoJS from 'crypto-js'
const roleUserApi: T.IRouleUserApi = {
  list(data) {
    return http.get('/admin/user/page', data)
  },
  detail(id) {
    return http.get(`/admin/user/details/${id}`)
  },
  add(data) {
    return http.post('/admin/user', data)
  },
  edit(data) {
    return http.put('/admin/user', data)
  },
  del(data) {
    return http.post('/admin/user/del', data.ids)
  },
  password(data) {
    return http.put('/admin/user/password', {
      password: CryptoJS.MD5(data.oldPass).toString(),
      newpassword1: data.password,
    })
  },
  password2(data) {
    return http.put('/admin/user/password2', {
      userId: data.userId,
      newpassword1: data.password,
    })
  },
}

export default roleUserApi
